/**
 * Dependencies:
 *      1. jquery
 *      2. lxn_pop.css
 * Usage:
 *      new LXN_select('parentId',{list列表元素1,list列表元素2,list列表元素3.....});
 * Ref:
 *
 * */
function LXN_select(parentId,options) {
    this.options = $.extend({
        listText    :   ['全部','已读','未读']
    }, options);
    var selectId = parentId + 'Select';

    var text = this.options.listText;

    var content = '<div class="select" id="'+ selectId +'">'+
        '<p class="selected">' +
        '<span>'+ text[0]+'</span>'+
        '<span class="select-icon"></span>'+
        '</p>'+
        '<ul class="select-list" style="display: none;">';

    for (var x in text)
    {
        content += '<li>'+ text[x] +'</li>' ;
    }
    content +=          '</ul></div>';

    $('#' + parentId).append(content);

    this.$wap = $('#'+ selectId);
    this.$selected = this.$wap.find('.selected');
    this.$selectList = this.$wap.find('.select-list');

    this.showDiv();
    this.closeDiv();
}
LXN_select.prototype.showDiv = function() {
    var $wap = this.$wap ;
    var $selected = this.$selected ;
    var $selectList = this.$selectList;

    $selected.click(function(){
        if($selectList.is(':visible')){
            $selectList.hide();
        }else{
            $selectList.show();
        }
        return false;
    })
};
LXN_select.prototype.closeDiv = function() {
    var $wap = this.$wap ;
    var $selected = this.$selected ;
    var $selectList = this.$selectList;

    $selectList.find("li").click(function() {
        $selected.children().first().text($(this).text());
        $selectList.hide();
    });
    $(document).click(function(){
        $selectList.hide();
        return false;
    })
};


